#include "gtkfilechooserentry.h"
#include "gtkfilechooserutils.h"
#include "gtkfilechooser.h"
-#include "gtkfilesystem.h"
#include "gtkfilesystemmodel.h"
#include "gtkgrid.h"
#include "gtkicontheme.h"
GtkFileChooserAction action;
- GtkFileSystem *file_system;
-
GtkWidget *box;
GActionGroup *item_actions;
if (impl->location_changed_id > 0)
g_source_remove (impl->location_changed_id);
- g_clear_object (&impl->file_system);
-
g_free (impl->browse_files_last_selected_name);
g_clear_object (&impl->filters);
};
static void
-name_exists_get_info_cb (GCancellable *cancellable,
- GFileInfo *info,
- const GError *error,
+name_exists_get_info_cb (GObject *source,
+ GAsyncResult *result,
gpointer user_data)
{
+ GFile *file = G_FILE (source);
struct FileExistsData *data = user_data;
+ GFileInfo *info;
GtkFileChooserWidget *impl = data->impl;
- if (cancellable != impl->file_exists_get_info_cancellable)
- goto out;
-
- impl->file_exists_get_info_cancellable = NULL;
-
- if (g_cancellable_is_cancelled (cancellable))
- goto out;
+ g_clear_object (&impl->file_exists_get_info_cancellable);
+ info = g_file_query_info_finish (file, result, NULL);
if (info != NULL)
{
gtk_widget_set_sensitive (data->button, FALSE);
/* Don't clear the label here, it may contain a warning */
}
-out:
g_object_unref (impl);
g_object_unref (data->file);
g_free (data);
- g_object_unref (cancellable);
+ g_clear_object (&info);
}
static void
if (impl->file_exists_get_info_cancellable)
g_cancellable_cancel (impl->file_exists_get_info_cancellable);
-
- impl->file_exists_get_info_cancellable =
- _gtk_file_system_get_info (impl->file_system,
- file,
- "standard::type",
- name_exists_get_info_cb,
- data);
+ g_clear_object (&impl->file_exists_get_info_cancellable);
+
+ impl->file_exists_get_info_cancellable = g_cancellable_new ();
+ g_file_query_info_async (file,
+ "standard::type",
+ G_FILE_QUERY_INFO_NONE,
+ G_PRIORITY_DEFAULT,
+ impl->file_exists_get_info_cancellable,
+ name_exists_get_info_cb,
+ data);
g_object_unref (file);
}
} FileListDragData;
static void
-file_list_drag_data_received_get_info_cb (GCancellable *cancellable,
- GFileInfo *info,
- const GError *error,
+file_list_drag_data_received_get_info_cb (GObject *source,
+ GAsyncResult *result,
gpointer user_data)
{
- gboolean cancelled = g_cancellable_is_cancelled (cancellable);
+ GFile *file = G_FILE (source);
FileListDragData *data = user_data;
+ GFileInfo *info;
GtkFileChooserWidget *impl = data->impl;
GtkFileChooser *chooser = GTK_FILE_CHOOSER (impl);
- if (cancellable != impl->file_list_drag_data_received_cancellable)
- goto out;
-
- impl->file_list_drag_data_received_cancellable = NULL;
+ g_clear_object (&impl->file_list_drag_data_received_cancellable);
- if (cancelled || error)
+ info = g_file_query_info_finish (file, result, NULL);
+ if (!info)
goto out;
if ((impl->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
impl->action == GTK_FILE_CHOOSER_ACTION_SAVE) &&
- data->files->next == NULL && !error && _gtk_file_info_consider_as_directory (info))
+ data->files->next == NULL && _gtk_file_info_consider_as_directory (info))
change_folder_and_display_error (data->impl, data->files->data, FALSE);
else
{
g_slist_free_full (data->files, g_object_unref);
g_free (data);
- g_object_unref (cancellable);
+ g_clear_object (&info);
}
static gboolean
if (impl->file_list_drag_data_received_cancellable)
g_cancellable_cancel (impl->file_list_drag_data_received_cancellable);
+ g_clear_object (&impl->file_list_drag_data_received_cancellable);
- impl->file_list_drag_data_received_cancellable =
- _gtk_file_system_get_info (impl->file_system, data->files->data,
- "standard::type",
- file_list_drag_data_received_get_info_cb,
- data);
+ impl->file_list_drag_data_received_cancellable = g_cancellable_new ();
+ g_file_query_info_async (data->files->data,
+ "standard::type",
+ G_FILE_QUERY_INFO_NONE,
+ G_PRIORITY_DEFAULT,
+ impl->file_list_drag_data_received_cancellable,
+ file_list_drag_data_received_get_info_cb,
+ data);
return TRUE;
}
G_OBJECT_CLASS (gtk_file_chooser_widget_parent_class)->constructed (object);
- g_assert (impl->file_system);
-
update_appearance (impl);
profile_end ("end", NULL);
{
pending_select_files_free (impl);
- g_clear_pointer (&impl->file_list_drag_data_received_cancellable, g_cancellable_cancel);
- g_clear_pointer (&impl->update_current_folder_cancellable, g_cancellable_cancel);
- g_clear_pointer (&impl->should_respond_get_info_cancellable, g_cancellable_cancel);
- g_clear_pointer (&impl->file_exists_get_info_cancellable, g_cancellable_cancel);
+ if (impl->file_list_drag_data_received_cancellable)
+ g_cancellable_cancel (impl->file_list_drag_data_received_cancellable);
+ g_clear_object (&impl->file_list_drag_data_received_cancellable);
+ if (impl->update_current_folder_cancellable)
+ g_cancellable_cancel (impl->update_current_folder_cancellable);
+ g_clear_object (&impl->update_current_folder_cancellable);
+ if (impl->should_respond_get_info_cancellable)
+ g_cancellable_cancel (impl->should_respond_get_info_cancellable);
+ g_clear_object (&impl->should_respond_get_info_cancellable);
+ if (impl->file_exists_get_info_cancellable)
+ g_cancellable_cancel (impl->file_exists_get_info_cancellable);
+ g_clear_object (&impl->file_exists_get_info_cancellable);
search_stop_searching (impl, TRUE);
}
};
static void
-update_current_folder_mount_enclosing_volume_cb (GCancellable *cancellable,
- GtkFileSystemVolume *volume,
- const GError *error,
- gpointer user_data)
+update_current_folder_mount_enclosing_volume_cb (GObject *source,
+ GAsyncResult *result,
+ gpointer user_data)
{
+ GFile *file = G_FILE (source);
struct UpdateCurrentFolderData *data = user_data;
GtkFileChooserWidget *impl = data->impl;
- gboolean cancelled = g_cancellable_is_cancelled (cancellable);
-
- if (cancellable != impl->update_current_folder_cancellable)
- goto out;
+ GError *error = NULL;
- impl->update_current_folder_cancellable = NULL;
+ g_clear_object (&impl->update_current_folder_cancellable);
set_busy_cursor (impl, FALSE);
- if (cancelled)
- goto out;
-
+ g_file_mount_enclosing_volume_finish (file, result, &error);
if (error)
{
error_changing_folder_dialog (data->impl, data->file, g_error_copy (error));
g_object_unref (data->file);
g_free (data);
- g_object_unref (cancellable);
+ g_clear_error (&error);
}
static void
-update_current_folder_get_info_cb (GCancellable *cancellable,
- GFileInfo *info,
- const GError *error,
+update_current_folder_get_info_cb (GObject *source,
+ GAsyncResult *result,
gpointer user_data)
{
- gboolean cancelled = g_cancellable_is_cancelled (cancellable);
+ GFile *file = G_FILE (source);
struct UpdateCurrentFolderData *data = user_data;
+ GFileInfo *info;
+ GError *error = NULL;
GtkFileChooserWidget *impl = data->impl;
- if (cancellable != impl->update_current_folder_cancellable)
- goto out;
-
- impl->update_current_folder_cancellable = NULL;
+ g_clear_object (&impl->update_current_folder_cancellable);
impl->reload_state = RELOAD_EMPTY;
set_busy_cursor (impl, FALSE);
- if (cancelled)
- goto out;
-
+ info = g_file_query_info_finish (file, result, &error);
if (error)
{
GFile *parent_file;
GMountOperation *mount_operation;
GtkWidget *toplevel;
- g_object_unref (cancellable);
+ g_clear_error (&error);
toplevel = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (impl)));
mount_operation = gtk_mount_operation_new (GTK_WINDOW (toplevel));
set_busy_cursor (impl, TRUE);
- impl->update_current_folder_cancellable =
- _gtk_file_system_mount_enclosing_volume (impl->file_system, data->file,
- mount_operation,
- update_current_folder_mount_enclosing_volume_cb,
- data);
+ impl->update_current_folder_cancellable = g_cancellable_new ();
+ g_file_mount_enclosing_volume (data->file,
+ G_MOUNT_MOUNT_NONE,
+ mount_operation,
+ impl->update_current_folder_cancellable,
+ update_current_folder_mount_enclosing_volume_cb,
+ data);
return;
}
g_object_unref (data->file);
data->file = parent_file;
- g_object_unref (cancellable);
+ g_clear_error (&error);
/* restart the update current folder operation */
impl->reload_state = RELOAD_HAS_FOLDER;
- impl->update_current_folder_cancellable =
- _gtk_file_system_get_info (impl->file_system, data->file,
- "standard::type",
- update_current_folder_get_info_cb,
- data);
+ impl->update_current_folder_cancellable = g_cancellable_new ();
+ g_file_query_info_async (data->file,
+ "standard::type",
+ G_FILE_QUERY_INFO_NONE,
+ G_PRIORITY_DEFAULT,
+ impl->update_current_folder_cancellable,
+ update_current_folder_get_info_cb,
+ data);
set_busy_cursor (impl, TRUE);
else
g_error_free (data->original_error);
+ g_clear_error (&error);
g_object_unref (data->original_file);
goto out;
g_object_unref (data->file);
g_free (data);
- g_object_unref (cancellable);
+ g_clear_object (&info);
}
static gboolean
if (impl->update_current_folder_cancellable)
g_cancellable_cancel (impl->update_current_folder_cancellable);
+ g_clear_object (&impl->update_current_folder_cancellable);
/* Test validity of path here. */
data = g_new0 (struct UpdateCurrentFolderData, 1);
impl->reload_state = RELOAD_HAS_FOLDER;
- impl->update_current_folder_cancellable =
- _gtk_file_system_get_info (impl->file_system, file,
- "standard::type",
- update_current_folder_get_info_cb,
- data);
+ impl->update_current_folder_cancellable = g_cancellable_new ();
+ g_file_query_info_async (file,
+ "standard::type",
+ G_FILE_QUERY_INFO_NONE,
+ G_PRIORITY_DEFAULT,
+ impl->update_current_folder_cancellable,
+ update_current_folder_get_info_cb,
+ data);
set_busy_cursor (impl, TRUE);
g_object_unref (file);
};
static void
-confirmation_confirm_get_info_cb (GCancellable *cancellable,
- GFileInfo *info,
- const GError *error,
+confirmation_confirm_get_info_cb (GObject *source,
+ GAsyncResult *result,
gpointer user_data)
{
- gboolean cancelled = g_cancellable_is_cancelled (cancellable);
+ GFile *file = G_FILE (source);
struct GetDisplayNameData *data = user_data;
+ GFileInfo *info;
- if (cancellable != data->impl->should_respond_get_info_cancellable)
- goto out;
-
- data->impl->should_respond_get_info_cancellable = NULL;
-
- if (cancelled)
- goto out;
+ g_clear_object (&data->impl->should_respond_get_info_cancellable);
- if (error)
+ info = g_file_query_info_finish (file, result, NULL);
+ if (!info)
goto out;
confirm_dialog_should_accept_filename (data->impl, data->file_part,
g_free (data->file_part);
g_free (data);
- g_object_unref (cancellable);
+ g_clear_object (&info);
}
/* Does overwrite confirmation if appropriate, and returns whether the dialog
if (impl->should_respond_get_info_cancellable)
g_cancellable_cancel (impl->should_respond_get_info_cancellable);
-
- impl->should_respond_get_info_cancellable =
- _gtk_file_system_get_info (impl->file_system, parent_file,
- "standard::display-name",
- confirmation_confirm_get_info_cb,
- data);
+ g_clear_object (&impl->should_respond_get_info_cancellable);
+
+ impl->should_respond_get_info_cancellable = g_cancellable_new ();
+ g_file_query_info_async (parent_file,
+ "standard::display-name",
+ G_FILE_QUERY_INFO_NONE,
+ G_PRIORITY_DEFAULT,
+ impl->should_respond_get_info_cancellable,
+ confirmation_confirm_get_info_cb,
+ data);
set_busy_cursor (data->impl, TRUE);
return FALSE;
}
static void
-name_entry_get_parent_info_cb (GCancellable *cancellable,
- GFileInfo *info,
- const GError *error,
+name_entry_get_parent_info_cb (GObject *source,
+ GAsyncResult *result,
gpointer user_data)
{
+ GFile *file = G_FILE (source);
+ struct FileExistsData *data = user_data;
+ GFileInfo *info;
gboolean parent_is_folder = FALSE;
gboolean parent_is_accessible = FALSE;
- gboolean cancelled = g_cancellable_is_cancelled (cancellable);
- struct FileExistsData *data = user_data;
GtkFileChooserWidget *impl = data->impl;
+ GError *error = NULL;
- if (cancellable != impl->should_respond_get_info_cancellable)
- goto out;
-
- impl->should_respond_get_info_cancellable = NULL;
+ g_clear_object (&impl->should_respond_get_info_cancellable);
set_busy_cursor (impl, FALSE);
- if (cancelled)
- goto out;
-
+ info = g_file_query_info_finish (file, result, &error);
if (info)
{
parent_is_folder = _gtk_file_info_consider_as_directory (info);
error_changing_folder_dialog (impl, data->parent_file, error_copy);
}
-out:
g_object_unref (data->impl);
g_object_unref (data->file);
g_object_unref (data->parent_file);
g_free (data);
- g_object_unref (cancellable);
+ g_clear_error (&error);
+ g_clear_object (&info);
}
static void
-file_exists_get_info_cb (GCancellable *cancellable,
- GFileInfo *info,
- const GError *error,
+file_exists_get_info_cb (GObject *source,
+ GAsyncResult *result,
gpointer user_data)
{
+ GFile *file = G_FILE (source);
+ struct FileExistsData *data = user_data;
+ GFileInfo *info;
gboolean data_ownership_taken = FALSE;
- gboolean cancelled = g_cancellable_is_cancelled (cancellable);
gboolean file_exists;
gboolean is_folder;
gboolean needs_parent_check = FALSE;
- struct FileExistsData *data = user_data;
GtkFileChooserWidget *impl = data->impl;
+ GError *error = NULL;
- if (cancellable != impl->file_exists_get_info_cancellable)
- goto out;
-
- impl->file_exists_get_info_cancellable = NULL;
+ g_clear_object (&impl->file_exists_get_info_cancellable);
set_busy_cursor (impl, FALSE);
- if (cancelled)
- goto out;
-
+ info = g_file_query_info_finish (file, result, &error);
file_exists = (info != NULL);
is_folder = (file_exists && _gtk_file_info_consider_as_directory (info));
if (impl->should_respond_get_info_cancellable)
g_cancellable_cancel (impl->should_respond_get_info_cancellable);
-
- impl->should_respond_get_info_cancellable =
- _gtk_file_system_get_info (impl->file_system,
- data->parent_file,
- "standard::type,access::can-execute",
- name_entry_get_parent_info_cb,
- data);
+ g_clear_object (&impl->should_respond_get_info_cancellable);
+
+ impl->should_respond_get_info_cancellable = g_cancellable_new ();
+ g_file_query_info_async (data->parent_file,
+ "standard::type,access::can-execute",
+ G_FILE_QUERY_INFO_NONE,
+ G_PRIORITY_DEFAULT,
+ impl->should_respond_get_info_cancellable,
+ name_entry_get_parent_info_cb,
+ data);
set_busy_cursor (impl, TRUE);
}
-out:
if (!data_ownership_taken)
{
g_object_unref (impl);
g_free (data);
}
- g_object_unref (cancellable);
+ g_clear_error (&error);
+ g_clear_object (&info);
}
static void
if (impl->file_exists_get_info_cancellable)
g_cancellable_cancel (impl->file_exists_get_info_cancellable);
-
- impl->file_exists_get_info_cancellable =
- _gtk_file_system_get_info (impl->file_system, file,
- "standard::type",
- file_exists_get_info_cb,
- data);
+ g_clear_object (&impl->file_exists_get_info_cancellable);
+
+ impl->file_exists_get_info_cancellable = g_cancellable_new ();
+ g_file_query_info_async (file,
+ "standard::type",
+ G_FILE_QUERY_INFO_NONE,
+ G_PRIORITY_DEFAULT,
+ impl->file_exists_get_info_cancellable,
+ file_exists_get_info_cb,
+ data);
set_busy_cursor (impl, TRUE);
}
g_signal_connect (impl, "notify::display,", G_CALLBACK (display_changed_cb), impl);
check_icon_theme (impl);
- impl->file_system = _gtk_file_system_new ();
impl->bookmarks_manager = _gtk_bookmarks_manager_new (NULL, NULL);
impl->filters = g_list_store_new (GTK_TYPE_FILE_FILTER);